// ****************************************************************************
// *     Filename:  MyHit.hh
// *  Description:  
// *      License:  Geant4 Software License 
// *                http://geant4.cern.ch/license/LICENSE.html
// *       Author:  Tran Hoai Nam (nam), nam@kuno-g.phys.sci.osaka-u.ac.jp
// * Organization:  Osaka University
// *      Created:  2012-09-14 12:57:35
// ****************************************************************************
#ifndef MYHIT_QUBW2A24
#define MYHIT_QUBW2A24

#include "G4Allocator.hh"
#include "G4ThreeVector.hh"
#include "G4THitsCollection.hh"
#include "G4ParticleDefinition.hh"
#include "G4VHit.hh"

class MyHit : public G4VHit {
	public:
		enum MyHitType {
			CaloHit,
			TrackerHit
		};
	public:
		MyHit ();
		~MyHit ();
		//const MyHit& operator = (const MyHit&){return *this;}
		//G4int operator == (const MyHit&) const;

		inline void *operator new(size_t);
		inline void operator delete(void *aHit);
		virtual void Draw();
		virtual void Print();

	private:
		MyHitType fHitType;
		//For calo-type hit
		G4double  fedep;
		G4String	fDetName;
		G4int			fCopyNo;
		//For tracker-type hit
		G4bool		fPriStopFlag;//is primary and stopped
		G4ThreeVector	fStopPoint;
		G4double	fStopTime;

		G4bool		fNewFlag;	//is new particle
		G4ThreeVector	fNewPoint;
		G4double	fNewTime;
		G4String	fNewName;
		G4int			fNewPID; //PDG encoding
		G4double	fNewKE;
		G4int			fNewTrackID;

		G4int			fDirection;	//-1: exit, 1: enter, 0: init
		G4double	fTime;
		G4double	fKE;
		G4String	fName;
		G4int			fPID; //PDG encoding
		G4int			fTrackID;
		G4ThreeVector	fPos;

	public:
		static bool Before(const MyHit& h1, const MyHit& h2);
		void SetHitType (MyHitType value) {fHitType = value;}
		MyHitType GetHitType() { return fHitType;}

		void Setedep (G4double value) {fedep = value;}
		G4double Getedep() { return fedep;}
		void SetDetName (G4String value) {fDetName = value;}
		G4String GetDetName() { return fDetName;}
		void SetCopyNo (G4int value) {fCopyNo = value;}
		G4int GetCopyNo() { return fCopyNo;}

		void SetPriStopFlag () {fPriStopFlag = true;}
		G4bool IsPriStopped() { return fPriStopFlag;}
		void SetStopPoint (G4ThreeVector value) {fStopPoint = value;}
		G4ThreeVector GetStopPoint() { return fStopPoint;}
		void SetStopTime (G4double value) {fStopTime = value;}
		G4double GetStopTime() { return fStopTime;}

		void SetNewFlag () {fNewFlag = true;}
		G4bool IsNew() { return fNewFlag;}
		void SetNewPoint (G4ThreeVector value) {fNewPoint = value;}
		G4ThreeVector GetNewPoint() { return fNewPoint;}
		void SetNewTime (G4double value) {fNewTime = value;}
		G4double GetNewTime() { return fNewTime;}
		void SetNewName (G4String value) {fNewName = value;}
		G4String GetNewName() { return fNewName;}
		void SetNewPID (G4int value) {fNewPID = value;}
		G4int GetNewPID() { return fNewPID;}
		void SetNewKE (G4double value) {fNewKE = value;}
		G4double GetNewKE() { return fNewKE;}
		void SetNewTrackID (G4int value) {fNewTrackID = value;}
		G4int GetNewTrackID() { return fNewTrackID;}

		void SetDirection (G4int value) {fDirection = value;}
		G4int GetDirection() { return fDirection;}
		void SetTime (G4double value) {fTime = value;}
		G4double GetTime() { return fTime;}
		void SetKE (G4double value) {fKE = value;}
		G4double GetKE() { return fKE;}
		void SetName (G4String value) {fName = value;}
		G4String GetName() { return fName;}
		void SetPID (G4int value) {fPID = value;}
		G4int GetPID() { return fPID;}
		void SetTrackID (G4int value) {fTrackID = value;}
		G4int GetTrackID() { return fTrackID;}
		void SetPos (G4ThreeVector value) {fPos = value;}
		G4ThreeVector GetPos() { return fPos;}
};

typedef G4THitsCollection<MyHit> MyHitsCollection;

extern G4Allocator<MyHit> MyHitAllocator;

inline void* MyHit::operator new(size_t)
{
	void* aHit;
	aHit = (void*)MyHitAllocator.MallocSingle();
	return aHit;
}

inline void MyHit::operator delete(void* aHit)
{
	MyHitAllocator.FreeSingle((MyHit*) aHit);
}

#endif /* end of include guard: MYHIT_QUBW2A24 */
